/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package MODEL;

import java.io.Serializable;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author ahmed
 */
@Entity
@Table(name = "COMMANDER")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Commander.findAll", query = "SELECT c FROM Commander c"),
    @NamedQuery(name = "Commander.findByIdF", query = "SELECT c FROM Commander c WHERE c.commanderPK.idF = :idF"),
    @NamedQuery(name = "Commander.findByIdItem", query = "SELECT c FROM Commander c WHERE c.commanderPK.idItem = :idItem"),
    @NamedQuery(name = "Commander.findByDatec", query = "SELECT c FROM Commander c WHERE c.datec = :datec"),
    @NamedQuery(name = "Commander.findByPrixAchat", query = "SELECT c FROM Commander c WHERE c.prixAchat = :prixAchat")})
public class Commander implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected CommanderPK commanderPK;
    @Column(name = "DATEC")
    @Temporal(TemporalType.TIMESTAMP)
    private Date datec;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "PRIX_ACHAT")
    private BigDecimal prixAchat;
    @JoinColumn(name = "ID_F", referencedColumnName = "ID_F", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Fournisseur fournisseur;

    public Commander() {
    }

    public Commander(CommanderPK commanderPK) {
        this.commanderPK = commanderPK;
    }

    public Commander(BigDecimal idF, BigDecimal idItem) {
        this.commanderPK = new CommanderPK(idF, idItem);
    }

    public CommanderPK getCommanderPK() {
        return commanderPK;
    }

    public void setCommanderPK(CommanderPK commanderPK) {
        this.commanderPK = commanderPK;
    }

    public Date getDatec() {
        return datec;
    }

    public void setDatec(Date datec) {
        this.datec = datec;
    }

    public BigDecimal getPrixAchat() {
        return prixAchat;
    }

    public void setPrixAchat(BigDecimal prixAchat) {
        this.prixAchat = prixAchat;
    }

    public Fournisseur getFournisseur() {
        return fournisseur;
    }

    public void setFournisseur(Fournisseur fournisseur) {
        this.fournisseur = fournisseur;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (commanderPK != null ? commanderPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Commander)) {
            return false;
        }
        Commander other = (Commander) object;
        if ((this.commanderPK == null && other.commanderPK != null) || (this.commanderPK != null && !this.commanderPK.equals(other.commanderPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "MODEL.Commander[ commanderPK=" + commanderPK + " ]";
    }
    
}
